//
// Dependencies
// --------------------------------------------------

@import "global.less";

//
// Lists
// --------------------------------------------------

@import "list.rowlink.less";
@import "list.base.less";

//
// List Data Table
//

table.table.data {
    .list-head-icon(@icon) {
        > span, > a {
            &:after {
                font-size: 14px;
                line-height: 14px;
                display: inline-block;
                margin-left: 6px;
                vertical-align: text-top;
                .opacity(.4);
                .icon(@icon);
            }
            &:hover:after { .opacity(.8); }
        }
    }

    .table-totals {
        background-color: #f2f2f2;

        span {
            display: block;
            color: @color-list-text-head;
        }

        td {
            border: 0;
        }
    }
    thead .table-totals span {
        text-align: center;
        padding: 6.5px 7.5px;
    }
    tfoot .table-totals {
        td {
            border-top: 2px solid @color-list-border;
        }
        span {
            text-align: right;
        }
    }

    font-size: @font-size-base - 1;
    border-bottom: 1px solid @color-list-border;

    &.no-offset-bottom {
        margin-bottom: 0 !important;
    }

    thead {
        background: @color-list-head-bg;

        td, th {
            border-width: 1px;
            border-top: 1px solid @color-list-border !important;
            border-bottom: 2px solid @color-list-border !important;
            border-color: @color-list-border;
            padding: 0;
            font-weight: normal;
            text-transform: uppercase;
            font-size: @font-size-base - 3;
            white-space: nowrap;

            > a, > span {
                display: block;
                padding: 13px 15px;
                color: @color-list-text-head;
                text-decoration: none;
                &:hover { color: @color-list-text-active; }
            }

            &.sortable { .list-head-icon(@angle-right); }
            &.sort-desc { .list-head-icon(@angle-down); }
            &.sort-asc { .list-head-icon(@angle-up); }

            &.active {
                background-color: inherit;
                > span, > a {
                    &:after {
                        color: @color-list-active-sort;
                        .opacity(1) !important;
                    }
                }
            }
        }

        tr th:first-child {
            padding-left: 10px;
        }

        tr th:last-child a {
            padding-right: 25px;
        }

        .list-checkbox .custom-checkbox {
            top: -16px;
        }
    }

    tbody {
        tr:nth-child(even) {
            td, th { background-color: @color-list-accent; }
        }
        td, th {
            padding: 12px 15px;
            color: @color-list-text;
            border-top: 2px solid white;

            a:not(.btn) {
                color: @color-list-text;
                &:hover {
                    text-decoration: none;
                }
            }

            div.progress {
                position: relative;
                overflow: visible;
                height:var(--progress-height, 18px);
                margin-bottom: 0;
                background-color: @color-list-progress-bg;
                .border-radius(0);
                .box-shadow(0 0 1px darken(@color-list-border, 50%));

                div.bar {
                    position: absolute;
                    left: -15px;
                    top: -11px;
                    bottom: -11px;
                    background: @color-list-progress-bg;
                    .opacity(0.3);
                }

                a {
                    position: relative;
                }
            }
        }

        tr:first-child {
            th, td {
                border-top-width: 0;
            }
        }

        tr:last-child {
            th, td {
                border-bottom-width: 0;
            }
        }

        tr td:first-child {
            border-left: 3px solid transparent;
            padding-left: 22px;
        }

        tr.active td {
            color: @color-list-text-active;

            &:first-child {
                border-left: 3px solid @color-list-stripe-active;
            }
        }

        tr.rowlink:not(.nolink):hover td, tr:not(.no-data).selected td {
            background: @color-list-hover-bg !important;
            color: @highlight-hover-text;

            a:not(.btn), span, i[class^="icon-"] {
               color: @highlight-hover-text;
            }

            div.progress {
                background-color: lighten(@color-list-hover-bg, 25%);
            }
        }

        tr.rowlink:not(.nolink):active td {
            background: @color-list-active-bg !important;
            color: @color-list-active-text;
        }

        tr.hidden {
            td, th, td a, th a {
                display: none;
            }
        }

        tr.strike {
            td, th, td a, th a {
                text-decoration: line-through;
            }
        }

        tr.frozen {
            td, th, td a, th a {
                color: #337ab7;
            }
        }

        tr.processing {
            td, th, td a, th a {
                color: #666666;
            }
        }

        tr.negative {
            td, th, td a, th a {
                color: #b2341c;
            }
        }

        tr.positive {
            td, th, td a, th a {
                color: #278731;
            }
        }

        tr.disabled, tr.deleted {
            td, th, td a, th a {
                color: #888888;
            }
        }

        tr.new, tr.important {
            td, th, td a, th a {
                font-weight: 600;
            }
        }

        tr.safe, tr.special {
            td, th, td a, th a {
                color: #98a7a8;
            }
        }

        td.column-break-word {
            word-wrap: break-word;
            word-break: break-all;
        }

        // Requires "max-width" with px value
        td.column-single-line {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        td.column-slim {
            padding-left: 0;
            padding-right: 0;
        }

        td.column-compact {
            padding: 0;
        }

        td.column-button {
            padding: 5px;
        }

        &.icons {
            td i[class^="icon-"] {
                display: inline-block;
                margin-right: 7px;
                font-size: 15px;
                color: #95a5a6;
                position: relative;
                top: 1px;
            }
        }

        &.clickable {
            cursor: pointer;
            .user-select(none);
        }
    }

    &.no-active-indicator tbody {
        tr td:first-child {
            border-left: none;
        }
    }

    tfoot {
        a {
            color: @color-list-text;
            text-decoration: none;
        }
        td, th {
            border-color: @color-list-border;
            padding: 10px 15px;
        }
    }

    th.list-cell-type-switch,
    td.list-cell-type-switch {
        text-align: center;
    }

    th.list-cell-type-number,
    td.list-cell-type-number {
        text-align: right;
    }

    th.list-cell-align-left,
    td.list-cell-align-left {
        text-align: left;
    }

    th.list-cell-align-right,
    td.list-cell-align-right {
        text-align: right;
    }

    th.list-cell-align-center,
    td.list-cell-align-center {
        text-align: center;
    }

    //
    // Labels
    //

    .list-badge {
        display: inline-block;
        position: relative;
        top: 0;
        margin: 0 5px 0 0;
        padding: 1px 0 0 0;
        font-size: 10px;
        width: 15px;
        height: 15px;
        text-align: center;
        border-radius: @border-radius-base;
        color: #fff;

        > i {
            position: relative;
            top: -1px;
        }

        &.badge-default {
            background: @gray-light;
        }

        &.badge-primary {
            background: @brand-primary;
        }

        &.badge-success {
            background: @brand-success;
        }

        &.badge-info {
            background: @brand-info;
        }

        &.badge-warning {
            background: @brand-warning;
        }

        &.badge-danger {
            background: @brand-danger;
        }
    }

    //
    // Checkbox
    //

    .list-checkbox {
        width: 52px;
        vertical-align: top;
        border-right: 1px solid @color-list-border-light;
        .checkbox {
            margin: 0;
            min-height: 0;
        }
        .custom-checkbox {
            position: relative;
            top: -14px;
            left: -2px;
            label {
                margin-right: 0;
                margin-bottom: 0;
            }
        }
    }

    tbody tr td.list-checkbox {
        padding-left: (@padding-standard - 3); // Offset the border
        padding-right: (@padding-standard - 17); // Offset the checkbox padding
    }

    thead tr th.list-checkbox {
        padding: 18px 0 0 @padding-standard;
    }

    //
    // Trees
    //

    .list-tree {
        width: 10px;
        padding: 0;
        padding-left: 0 !important;
        vertical-align: middle;

        a.list-expand-collapse {
            padding: 5px;
            display: block;
            text-align: center;
            font-size: 14px;
            position: relative;
            text-decoration: none !important;
            color: @color-list-text-tree;
        }
    }

    // Tree levels 1 - 10
    .makeTreeLevel(@count) {
        tr.list-tree-level-@{count} {
            a.list-expand-collapse { left: 10px + (10 * @count); }
            td.list-cell-index-1 { padding-left: 15px + (10 * @count); }
        }
    }

    .makeTreeLevel(0);
    .makeTreeLevel(1);
    .makeTreeLevel(2);
    .makeTreeLevel(3);
    .makeTreeLevel(4);
    .makeTreeLevel(5);
    .makeTreeLevel(6);
    .makeTreeLevel(7);
    .makeTreeLevel(8);
    .makeTreeLevel(9);
    .makeTreeLevel(10);
}

//
// List containers
//

.list-preview {
    padding: 0;
    margin-bottom: 20px;
    background: white;
    border: 1px solid @color-list-border;

    .list-header:first-child {
        padding-top: 20px;
    }

    .control-list:last-child {
        margin-bottom: 0;
    }

    .control-list:last-child > table {
        border-bottom: none;
    }
}

// List to sit flush to the element above (no toolbar)
.list-flush {
    table.table.data {
        thead tr th {
            border-top: none !important;
        }
    }
}

// List with sidebar
.list-with-sidebar {
    table.table.data {
        border-left: 1px solid @color-list-border;
    }
}

//
// List control
//

.control-list {
    margin-bottom: @line-height-computed;

    p.no-data {
        padding: 18px 20px;
        margin: 0 20px;
        color: @color-list-norecords-text;
        font-size: @font-size-base - 1;
        text-align: center;
        font-weight: 300;
        .border-radius(@border-radius-base);
    }

    table.table.data {
        margin-bottom: 0;

        .list-setup {
            width: 48px;
            a {
                display: block;
                color: #000000;
                &:before {
                    font-size: 14px;
                    line-height: 14px;
                    .icon(@list-ul);
                    display: inline-block;
                    margin-left: 8px;
                    vertical-align: baseline;
                    .opacity(.6);
                }

                &:hover:before {
                    .opacity(1);
                    color: @color-list-hover-bg !important;
                }
            }
        }
    }
}

.list-header {
    background-color: @color-list-header-bg;
    padding: 0 @padding-standard 1px @padding-standard;

    h3 {
        font-size: 14px;
        color: @color-status-list-text;
        text-transform: uppercase;
        font-weight: 600;
        margin-top: 0;
        margin-bottom: 15px;
    }
}

.list-footer {
    padding: 10px 15px;

    a {
        color: @color-list-text;
        text-decoration: none;
    }

    .list-pagination {
        font-size: 14px;
        text-align: right;
        padding-top: 10px;
        overflow: hidden; /* clearfix */

        .loading-indicator {
            div {
                margin-left: 20px;
                font-size: 12px;
            }
        }
    }
}

.report-widget {
    .table-container {
        margin: -15px;

        table.table.data {
            margin-bottom: 0;

            thead tr {
                th {
                    border-top: none !important;
                }
            }

            tbody {
                tr:nth-child(even) {
                    td, th { background-color: transparent; }
                }
            }
        }
    }
}

//
// Scrollable list control
//

.list-scrollable-container {
    touch-action: auto;
    position: relative;

    .horizontal-scroll-indicators(@color-list-text-head);

    &:after, &:before {
        margin-top: 0;
        height: 40px;
        padding: 13px 10px;
        background: #fff;
        top: 1px;
    }

    &:before {
        left: 0;
    }

    &:after {
        right: 0;
    }

    > .list-scrollable {
        overflow: hidden;
    }

    &.scroll-after th a,
    &.scroll-before th a {
        cursor: grab;
    }
}
